<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>add</title>
    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

</head>
<body>
<div class="container">
    <form role="form" id="ddd" class="form-horizontal">
        <div class="form-group">
            <label for="firstname" class="col-sm-2 control-label">名字</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="name">
            </div>
        </div>

        <div class="form-group">
            <label for="firstname" class="col-sm-2 control-label">工作</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="job" >
            </div>
        </div>

        <div class="form-group">
            <label for="firstname" class="col-sm-2 control-label">工资</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="sal">
            </div>
        </div>
        <input class="btn btn-primary" type="button" value="添加" @click="add()">
    </form>
</div>
<!--引入axios框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el:"form",
        data:{},
        methods:{
            add:function () {
                let data = new FormData(document.querySelector("form"));
                axios.post("/add",data).then(function () {
                    alert("添加成功")
                    location.href="/index.html"
                })
            }
        }
    })
</script>
</body>
</html>